﻿using HttpApiGateway.Interface;
using RpcClient.Interface;

namespace HttpApiGateway.Idempotent
{
    [RpcClient.Attr.ClassLifetimeAttr(RpcClient.Attr.ClassLifetimeType.单例)]
    public class KeyIdempotent : IKeyIdempotent
    {
        private readonly ITokenIdempotent _Service;

        public KeyIdempotent(IIdempotentConfig config, IUnityCollect unity)
        {
            _Service = unity.Resolve<ITokenIdempotent>(config.SaveType.ToString());
        }

        public StatusSaveType SaveType => _Service.SaveType;


        public void Dispose()
        {
            _Service.Dispose();
        }

        public bool SubmitToken(string tokenId)
        {
            return _Service.SubmitToken(tokenId);
        }
    }
}
